from bisheng.api.jsj_api.model.metro_fault import MetroConfig, ConfigDao
from bisheng.api.jsj_api.model.metro_kv import MetroKV, MetroKVDao


class ConfigService:
    @staticmethod
    def create_config(key: str, value: str, remark: str):
        new_config = MetroConfig(key=key, value=value, remark=remark)
        return ConfigDao.create_config(new_config)

    @staticmethod
    def get_config_by_key(key: str):
        return ConfigDao.get_config_by_key(key)

    @staticmethod
    def get_config():
        return ConfigDao.get_config()

    @staticmethod
    def update_config(key: str, value: str, remark: str):
        return ConfigDao.update_config_by_key(key, {"value": value, "remark": remark})

    @staticmethod
    def create_kv(key: str, value: str, type: str):
        new_kv = MetroKV(key=key, value=value, type=type)
        return MetroKVDao.create_metro_kv(new_kv)

    @staticmethod
    def get_kv_by_key(key: str,type: str):
        return MetroKVDao.get_v_by_type_and_key(type, key)


